<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      #resetBtn {
        font-size: 24px;
        padding: 8px;
        margin: 40px;
      }

    </style>
  </head>

  <body>
    <button id="resetBtn" onclick="submit()">开始重置</button>
    <script>
      function submit() {
        const xhr = new XMLHttpRequest()
        xhr.open('get', '/reset')
        xhr.send()
        xhr.onload = function () {
          if (xhr.responseText === '恢复房产数据成功') {
            const btn = document.querySelector('#resetBtn')
            btn.disabled = true
            btn.innerHTML = '正在重置数据..'
            setTimeout(() => {
              btn.innerHTML = '等待服务重启...'
              setTimeout(() => {
                btn.innerHTML = '开始重置'
                btn.disabled = false
                alert('重置成功')
              }, 3000);
            }, 2000);
          } else {
            alert('重置失败')
          }
        }
      }
    </script>
  </body>

</html>
